package com.jwater.web.ui.tag.components;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.ClosingUIBean;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;

import com.opensymphony.xwork2.util.ValueStack;

@StrutsTag(name = "tab", tldTagClass = "com.jwater.web.ui.tags.TabTag", description = "tab", allowDynamicAttributes = true)
public class Tab extends ClosingUIBean {

	public static final String TEMPLATE = "tab";
	public static final String TEMPLATE_CLOSE = "tab-close";
	public static final String COMPONENT_NAME = Tab.class.getName();
	
	protected String tabsalign="left";

	@StrutsTagAttribute(description="tabs align,option:left,right ", type="String")
	public void setTabsalign(String tabsalign) {
		this.tabsalign = tabsalign;
	}

	public Tab(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
		super(stack, request, response);
	}

	@Override
	public String getDefaultOpenTemplate() {
		return TEMPLATE;
	}

	@Override
	protected String getDefaultTemplate() {
		return TEMPLATE_CLOSE;
	}

	@Override
	protected void evaluateExtraParams() {
		// TODO Auto-generated method stub
		super.evaluateExtraParams();
		if (tabsalign != null)
			addParameter("tabsalign", findString(tabsalign));
	}
	
}
